< previous page page_957 next page >

Page 957
It is better form, however, to assign the RecordSource to a variable that has been defined and points to the data table. Here's an example:
Dim cTable as String' Declare the variable
cTable = "Vendors" ' Establish the name of the table
Data1.RecordSource = cTable ' Set the data control
Data1.Refresh ' Update the data control
3. The UpdateControls method takes information from the underlying database table and places it in the form controls; whereas the UpdateRecord method takes information entered into the form controls and updates the attached table.
4. Checkboxes should only be bound to Boolean fields and can only produce values of 0 (No or False) and 1 (Yes or True).
5. You use the DataField property to bind a control to a table field.
6. The standard color for a Windows 95 form is light gray. Input areas are white. Display-only controls are light gray. Labels are left-aligned.
Answers to Day 4 Exercises
1. You should enter the following code as a new procedure in the general declarations section:
Sub OpenDB()
'Declare the variable for the name of the database
Dim cDBName as String
'Assign the variable to a database, including the path
cdbName = App.Path + " \Students.MDB"
'Set the name of the database used by the data control
Data1.DatabaseName = cDBName
'Refresh and update the data control
Data1.Refresh
End Sub
2. Your code should look like this:
Sub OpenDB()
 'Declare the variable for the name of the database
Dim cDBName as String
'Declare the variable for the table
Dim cTable as String
'Assign the variable to a database, including the path
cdbName = App.Path + "\Students.MDB"
'Assign the variable to the appropriate table
cTable = "Addresses"
'Set the name of the database used by the data control
Data1.DatabaseName = cDBName
'Set the name of the table used by the data control
Data1.RecordSource = cTable
'Refresh and update the data control
Data1.Refresh
End Sub

 
< previous page page_957 next page >

If you like this book, buy it!